import { UpdateAddressFormDataProps } from '@/components/UpdateAddress/interface'
import { AppContext } from '@/pages/App/context'
import { useContext, useImperativeHandle, useRef } from 'react'
import { ipViewProps } from '../interface'

const useAddressHook = (props: ipViewProps, ref: any) => {
	const AppData = useContext(AppContext)
	const userInfo = AppData.user
	/**
	 * 暴露组件的方法
	 */
	useImperativeHandle(ref, () => ({
		/**保存数据 */
		// saveData: () => {
		// 	ipRef.current && ipRef.current.saveData()
		// },
	}))
	const onChange = (formData: UpdateAddressFormDataProps[]) => {
		// props.onChange && props.onChange(formData)
	}
	const toSave = () => {
		// ipRef.current && ipRef.current.saveData()
	}
	return { onChange, toSave, userInfo }
}
export default useAddressHook
